package com.acoreful.acf2admin.tree;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Set;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

public class TreeUtils {
	public static void main(String[] args) {
		List<Node> list=getNodeList();
		Set<Integer> ids=getIds();
		System.out.println(JSON.toJSONString(ids));
		System.out.println(JSON.toJSONString(list));
		for (Node node : list) {
			node.setChildren(Arrays.asList(new Node(),new Node()));
		}
		System.out.println(list.size());
		System.out.println();
	}
	private static List<Node> getNodeList(){
		List<Node> list=Lists.newArrayList();
		int pid=0;
		int subNodeSize=5;
		int counter=0;
		Random r= new Random();
		for (int i = 0; i < 1000; i++) {
			counter++;
			list.add(new Node(i, "name"+i+"-"+counter, pid));
			if(counter==subNodeSize){
				subNodeSize=r.nextInt(20);
				counter=0;
				pid++;
			}
		}
		return list;
	}
	/*private static Node findById(List<Node> list,Integer id){
		
	}*/
	private static Set<Integer> getIds(){
		Set<Integer> list=Sets.newHashSet();
		Random r=new Random();
		for (int i = 0,len=r.nextInt(200)+100; i < len; i++) {
			list.add(r.nextInt(1000));
			
		}
		return list;
	}
}
